package com.yanqu.road.server.manger.activity.zhenhuan.service;

import com.google.protobuf.InvalidProtocolBufferException;
import com.yanqu.road.pb.activity.ZhenHuanProto;
import com.yanqu.road.pb.syncMessage.SyncMessage;
import com.yanqu.road.server.GameServer;
import com.yanqu.road.server.game.service.IGameServiceCommand;
import com.yanqu.road.server.manger.activity.zhenhuan.ZhenHuanMgr;
import com.yanqu.road.sync.message.SyncResponse;

public class ZhenHuanPromotionSyncServiceCmd implements IGameServiceCommand {
    @Override
    public SyncResponse execute(SyncMessage.Request request) throws InvalidProtocolBufferException {
        SyncResponse syncResponse = new SyncResponse();
        ZhenHuanProto.ZhenHuanPromotionListSyncMsg syncMsg = ZhenHuanProto.ZhenHuanPromotionListSyncMsg.parseFrom(request.getDataBytes());

        ZhenHuanMgr.setPromotion(syncMsg.getActivityId(), syncMsg.getInfoList());

        ZhenHuanProto.ZhenHuanPromotionListSyncConfirmMsg.Builder confirmMsg = ZhenHuanProto.ZhenHuanPromotionListSyncConfirmMsg.newBuilder();
        confirmMsg.setActivityId(syncMsg.getActivityId());
        confirmMsg.setServerId(GameServer.getInstance().getServerId());

        syncResponse.setResponseBuilder(confirmMsg);
        return syncResponse;
    }
}
